package homework2;

import java.util.Scanner;

public class ProductDisplayTest {
    public static void main(String[] args) {
        //创建一个Scanner对象
        Scanner sc = new Scanner(System.in);
        //把商品装进数组中
        Product[] products = {
                new Product(1, "商品1", "种类1", 10.0, 100, 50),
                new Product(2, "商品2", "种类2", 20.0, 200, 30),
                new Product(3, "商品3", "种类1", 15.0, 150, 70),
                new Product(4, "商品4", "种类2", 25.0, 250, 20)
        };
        System.out.println("请选择你要进行排序的方式");
        int choice = sc.nextInt();
        //根据选择的方式进行排序
        switch (choice){
            case 1:
                // 按照库存排列展示
                ProductSort stockSort = new StockProductSort();
                stockSort.sort(products);
                System.out.println("按照库存排列展示：");
                for (Product product : products) {
                    System.out.println(product);
                }
                break;
            case 2:
                // 按照价格排列展示
                ProductSort priceSort = new PriceProductSort();
                priceSort.sort(products);
                System.out.println("按照价格排列展示：");
                for (Product product : products) {
                    System.out.println(product);
                }
                break;
            case 3:
                // 默认按照销量排列展示
                ProductSort defaultSort = new DefaultProductSort();
                defaultSort.sort(products);
                System.out.println("按照销量排列展示：");
                for (Product product : products) {
                    System.out.println(product);
                }
                break;
            default:
                System.out.println("没有你要选择的方式");
        }
    }
}